package com.lune.job.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lune.job.mapper.IntentionMapper;
import com.lune.job.pojo.Intention;
import com.lune.job.service.IIntentionService;
import com.lune.job.service.IResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Caiyilin
 * @since 2022-03-06
 */
@Service
public class IntentionServiceImpl extends ServiceImpl<IntentionMapper, Intention> implements IIntentionService {


    @Autowired
    private IntentionMapper intentionMapper;
    @Autowired
    private IResumeService resumeService;

    @Override
    public IPage<Intention> queryPage(Integer currentPage, Integer size, Intention intention) {
        Page<Intention> page = new Page<>(currentPage, size);
        IPage<Intention> intentionIPage = intentionMapper.queryPage(page, intention);
        return intentionIPage;
    }

    @Override
    public List<Intention> queryByCon(Intention intention) {
        List<Intention> intentions = intentionMapper.queryByCon(intention);
        intentions.forEach(item -> {
            item.setResume(resumeService.getById(item.getResume_id()));
        });
        return intentions;
    }
}
